package com.bite.product.api;


import com.bite.product.model.ProductInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Feign客户端接口
 * 声明接口，Feign会根据接口方法定义，生成代理对象，并调用服务
 */

@FeignClient(name = "product-service", path = "/product")
public interface ProductApi {
    @RequestMapping("/{productId}")
    ProductInfo getProductById(@PathVariable("productId") Integer productId);

    @RequestMapping("/basic")
    String basicType(@RequestParam("id") Integer id, @RequestParam("name") String name);

    @RequestMapping("/object")
    String objectType(@SpringQueryMap ProductInfo productInfo);

    @RequestMapping("/json")
    String jsonType(@RequestBody ProductInfo productInfo);
}

